
#ifndef _APP_H_
#define _APP_H_


#include "dac6587.h"

#include "tcpip.h"





#define POWER_MAGIC 'P'
#define IOCTL_CMP_ON	_IOW	(POWER_MAGIC, 1, int)
#define IOCTL_CMP_OFF	_IOW	(POWER_MAGIC, 2, int)
#define IOCTL_PZT_ON	_IOW	(POWER_MAGIC, 3, int)
#define IOCTL_PZT_OFF	_IOW	(POWER_MAGIC, 4, int)



#define STATE_POWERUP		0x01
#define STATE_POWERDOWN		0x02

//#define PRINT_OPEN

#ifdef PRINT_OPEN 
#define PRINT_OPEN_APP	1
#else
#define PRINT_OPEN_APP	1
#endif



#define ERROR		-1
#define NOERROR		0


#define LDPVOLTAGEMAX	15500
#define LDPVOLTAGEMIN	14500



struct ConterSet					//set counter 
{
	unsigned int		u32EnableCh1;		// set enable		
	unsigned int		u32FreqCh1;			// set frequence - Hz
	unsigned int		u32HihtVoltTimeCh1;	// set hiht voltage time us
	unsigned int		u32MaxFreqCh1;		// set Maxim frequence			
	unsigned int		u32MinFreqCh1;		// set minim frequence	
	unsigned int		u32ChannelCh1;		// set Channel 1
	
	unsigned int		u32EnableCh2;		// set enable
	unsigned int		u32FreqCh2;			// set frequence - Hz
	unsigned int		u32HihtVoltTimeCh2;	// set hiht voltage time us
	unsigned int		u32MaxFreqCh2;		// set Maxim frequence			
	unsigned int		u32MinFreqCh2;		// set minim frequence	
	unsigned int		u32ChannelCh2;		// set Channel 1

	unsigned int		u32Version;			//Version
	
};
struct DacSet
{
	unsigned int		u32VoltageCh1;
	unsigned int		u32MaxVoltageCh1;
	unsigned int		u32MinVoltageCh1;
	
	unsigned int		u32CurrentCh1;
	unsigned int		u32MaxCurrentCh1;
	unsigned int		u32MinCurrentCh1;;
	
	unsigned int		u32VoltageCh2;
	unsigned int		u32MaxVoltageCh2;
	unsigned int		u32MinVoltageCh2;
	
	unsigned int		u32CurrentCh2;	
	unsigned int		u32MaxCurrentCh2;
	unsigned int		u32MinCurrentCh2;;
};

struct Config
{
	struct ConterSet stCounterSet;
	struct DacSet	stDacSet;
	
};
struct SysError
{
	int HeartError;
	int UdpError;
	int AdcError;
	int DacError;
	int CounterError;
};

struct SysFlag
{
	int	s32ConfigUpdata;
	int	s32ConfigPowerUp;
	
};
struct SysState
{
	int s32StatePowerFaultCh1;
	int s32StatePowerUpCh1;
	int s32StateLMFaultCh1;
	int s32StateTempFaultCh1;
	int	s32StateVoltageFaultCh1;
	int s32StateCurrentFaultCh1;
	int	s32StateInterLockCh1;

	int s32StatePowerFaultCh2;
	int s32StatePowerUpCh2;
	int s32StateLMFaultCh2;
	int s32StateTempFaultCh2;
	int	s32StateVoltageFaultCh2;
	int s32StateCurrentFaultCh2;
	int	s32StateInterLockCh2;
	
};

struct SysParameter
{
	unsigned int u32VoltageCh1;
	unsigned int u32ParameterVoltageCh1;
	unsigned int u32ParametercurrentCh1;

	unsigned int u32VoltageCh2;
	unsigned int u32ParameterVoltageCh2;
	unsigned int u32ParametercurrentCh2;
};

static int ParameterSet(struct Config *pConfig);
static int PowerUpSet(int temp);

static int LdpCheck(void);



#endif




